package com.zmn.oms.dubbo.impl.normal.order;

import com.zmn.common.dto2.ResponseDTO;
import com.zmn.oms.business.interfaces.orderamount.OrderAmountCheckBService;
import com.zmn.oms.common.constant.OmsErrorCodeConsts;
import com.zmn.oms.dubbo.interfaces.normal.order.OrderAmountCheckRemoteService;
import com.zmn.oms.dubbo.utils.DubboConsts;
import com.zmn.oms.model.entity.work.OrderWork;
import com.zmn.oms.services.interfaces.work.OrderWorkService;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * @author sunlife
 * @date:2022/1/14 11:07 上午
 * description:
 */
@Slf4j
@Service(loadbalance = "roundrobin", timeout = 10000, retries = 0, version = DubboConsts.INTERFACE_VERSION, validation = "true")
public class OrderAmountCheckRemoteServiceImpl implements OrderAmountCheckRemoteService {

    @Autowired
    OrderAmountCheckBService orderAmountCheckBService;
    @Autowired
    OrderWorkService orderWorkService;

    @Override
    public ResponseDTO<Integer> checkShowMobileInput(Long orderId, Long workId) {
        OrderWork orderWork = orderWorkService.findOrderWorkByKey(orderId, workId);
        if (orderWork == null) {
            return ResponseDTO.fromErrorCodeTable(OmsErrorCodeConsts.ORDER_NOT_FOUND);
        }
        return ResponseDTO.success(orderAmountCheckBService.checkShowMobileInput(orderWork));
    }
}
